package com.cgbl.cg.adapter

import android.widget.TextView
import com.blankj.utilcode.util.ColorUtils
import com.cgbl.cg.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class LabelAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.app_item_label) {

    override fun convert(holder: BaseViewHolder, item: String) {
        val num = (0..3).random()
        setTextBgAndColor(holder.getView(R.id.item_tv_label), num)
        holder.setText(R.id.item_tv_label, item)
    }

    private fun setTextBgAndColor(view: TextView, index: Int) {
        when (index) {
            0 -> {
                view.setBackgroundResource(R.drawable.app_round_8_ffd4ad_0880)
                view.setTextColor(ColorUtils.getColor(R.color.app_DE7D24))
            }
            1 -> {
                view.setBackgroundResource(R.drawable.app_round_8_c4e6ff_0880)
                view.setTextColor(ColorUtils.getColor(R.color.app_2B72FF))
            }
            2 -> {
                view.setBackgroundResource(R.drawable.app_round_8_c5ffcb_0880)
                view.setTextColor(ColorUtils.getColor(R.color.app_12A51F))
            }
            else -> {
                view.setBackgroundResource(R.drawable.app_round_8_ffa8a8_0880)
                view.setTextColor(ColorUtils.getColor(R.color.app_D93131))
            }

        }
    }
}